Developing RESTful Web Services with Jersey 2.0 by 2013

Developing RESTful Web Services with Jersey 2.0 by 2013

Author:2013
Language: eng
Format: mobi
Publisher: Packt Publishing


The put method

The HTTP put method invokes the request. This method is requested synchronously by default:

WebTarget target = client.target("http://localhost:8080/Chapter2/services/putResource"); MultivaluedMap<String, String> putForm = new MultivaluedHashMap<String, String>(); putForm.add("name", "John"); String responseData = target.request().put(Entity.form(putForm),String.class);

It is the same as the post method. In order to consume the put method, we have the put(...) method of the Builder class.

On the server side, it will first identify the root-resource getResource and then check for the matching resource method put() to process the request. The resource method is mapped according to the matching URI template, that is, either a subresource or the validator, or the @Produces media type or the @Consumes media type is applied on resource method:

@PUT public String put(@FormParam("name") String name){ return "Hello, " + name; }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.